<script src="/assets/backend/static/jquery.upload.js"></script>
<form id="link_edit_dialog_form" action="/b/link/edit" method="post">
    <table width="100%" class="mdoutable">
        <tr>
            <td>名称：</td>
            <td>
                <input name="name" class="easyui-textbox" type="text" style="width: 250px;" value="{{.link.Name}}" data-options="required:true"/>
                <input type="hidden" name="linkid" value="{{.link.Linkid}}">
            </td>
        </tr>
        <tr>
            <td>Logo：</td>
            <td>
                {{.imageUploader}}
            </td>
        </tr>
        <tr>
            <td>链接：</td>
            <td><input name="url"  class="easyui-textbox" type="text" style="width: 250px;" value="{{.link.Url}}" data-options="required:true,validType: 'url'"/></td>
        </tr>
        <tr>
            <td>描述：</td>
            <td><textarea name="introduce" style="width:450px;height:60px; resize: none">{{.link.Introduce}}</textarea></td>
        </tr>

        <tr>
            <td>是否启用：</td>
            <td>
                <input class="easyui-switchbutton" name="passed" {{if eq .link.Passed 1}}checked{{end}} data-options="onText:'是',offText:'否'">
            </td>
        </tr>
    </table>
</form>

<script type="text/javascript">
    function linkListEditDialogFormSubmit() {
        $("#link_edit_dialog_form").form("submit", {
            success: function (res) {
                res = JSON.parse(res)
                if (res.errcode) {
                    $.messager.alert('提示信息', res.errmsg, 'error');
                } else {
                    $.messager.alert('提示信息', res.errmsg, 'info');
                    $('#link_list_edit_dialog').dialog('close');
                    linkListRefresh();
                }
            }
        })
    }

    $('#link_edit_news_form_thumb_input').click(function (e) {
        e.preventDefault();
        $.upload({
            url: "/public/upload",
            fileName: 'filedata',
            params: {},
            dataType: 'json',
            onSend: function () {
                return true;
            },
            onComplate: function (data) {
                if (0 === Number(data.errcode)) {
                    $("#link_edit_news_form_thumb_input").attr('src', data.errmsg);
                    $("#link_edit_news_form_thumb_input").next('input:hidden').val(data.errmsg);
                } else {
                    parent.$.messager.alert('提示信息', data.errmsg, 'error');
                }
            }
        });
        return false;
    });
</script>
